<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>阶乘</title>
</head>
<body>
    <script>
        var sum = 0;
        var a = 1;
        for(var i = 1; i<=10;i++){
            a = a*i;
            sum+=a;
        }
        document.write("1~10的阶乘为:"+sum);
    </script>
</body>
</html>